<?php
    class _sidebar_controller extends Controller
    {
        public function __construct(){
            parent::__construct();
            $this->load->helper('sidebar_helper');
            $this->load->library('auth');
        }
        
        public function display($options = null){
            $sidebar = $this->load->view(transLang('layout/sidebar'));
            $sidebar->assign($this->load->lang('sidebar'));
            if (null != $options)
                $sidebar->assign($options);
            $url = strrev(Utils::getRequestUrl());
            
            //remove login regist or doLogout page url encoding suffix
            //using reverse string removing, see the things in mirror ^_^, little trick
            if (
            	($pos = stripos($url, '/nigol')) || 
                ($pos = stripos($url, '/tsiger')) || 
                ($pos = stripos($url, '/tuogoldo'))){
            	//need removing
            	$redirect = strrev(substr($url, 0, $pos));
            }
            else{
            	$redirect = base64_encode(strrev($url));
            }
            
            $hasLogin = $this->load->model('user')->isLogin();
            
            $sidebar->assign(array('page_redirect' => '/' . $redirect, 'haslogin' => $hasLogin));
            $sidebar->display();
        }
    }
